using UnityEngine;

public class CallibrationControllerLayer : MonoBehaviour
{
	public RacketControlDataSender racket;

	public UILabel autosendButtonLabel;

	public UILabel attitude;

	public UILabel rotationRate;

	public UILabel rotationRateUnbiased;

	private void OnEnable()
	{
		Screen.sleepTimeout = -1;
		Input.gyro.enabled = true;
		Input.gyro.updateInterval = 0.01f;
		Input.compass.enabled = true;
		racket.sendDataContinuously = false;
		UITools.ChangeText(autosendButtonLabel, "Enable Autosend");
	}

	public void OnCallibrationSubmitted()
	{
		racket.SendDataNow(true);
	}

	public void PressAutoSendingButton()
	{
		racket.sendDataContinuously = !racket.sendDataContinuously;
		UITools.ChangeText(autosendButtonLabel, (!racket.sendDataContinuously) ? "Enable Autosend" : "Disable Autosend");
	}

	private void Update()
	{
		UITools.ChangeText(attitude, Input.gyro.attitude.eulerAngles.ToString());
		UITools.ChangeText(rotationRate, Input.gyro.rotationRate.ToString());
		UITools.ChangeText(rotationRateUnbiased, Input.gyro.rotationRateUnbiased.ToString());
	}
}
